package cn.com.dhc.danlu.fragment;

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.fragment.base.BaseBridgeFragment;
import cn.com.dhc.danlu.fragment.bridge.FragmentBridge;
import cn.com.dhc.danlu.util.CommonUtils;
import cn.com.dhc.danlu.widget.dialog.ViewDialog;

/**
 * @author wuhaiyang
 */
public class SelectActiveFragment extends BaseBridgeFragment implements View.OnClickListener {
    @Override
    public void onClick (View v) {
        if (v.getId () == R.id.rl_item_canreceive) {
            mBridgeCallback.onHandle (FragmentBridge.TYPE_GO_REMOVE_BIND, null);
        } else if (v.getId () == R.id.rl_item_cannotreceive) {
            new ViewDialog.Builder (getActivity ()).setMessage ("确定拨打400-011-6666").setCancelable (false)
                    .setNegativeButton (R.string.btn_cancel, new OnClickListener () {
                        @Override
                        public void onClick (DialogInterface dialog, int which) {
                            dialog.dismiss ();
                        }
                    })
                    .setPositiveButton (R.string.btn_confirm, new OnClickListener () {
                        @Override
                        public void onClick (DialogInterface dialog, int which) {
                            dialog.dismiss ();
                            CommonUtils.callHelp (getActivity ());
                        }
                    }).create ().show ();
        }
    }

    @Override
    public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate (R.layout.dl_fragment_selectactive, container, false);
    }

    @Override
    public void onViewCreated (View view, Bundle savedInstanceState) {
        super.onViewCreated (view, savedInstanceState);
        view.findViewById (R.id.rl_item_canreceive).setOnClickListener (this);
        view.findViewById (R.id.rl_item_cannotreceive).setOnClickListener (this);
    }
}